<template>
  <transition>
    <div class="lingdang" @click="jump">
      <i class="iconfont icon-lingdang"></i>
      <div v-if="num != '0'">
        <span>{{num}}</span>
      </div>
    </div>
  </transition>
</template>

<script>
export default {
  data() {
    return {
      num: ""
    };
  },
  created() {
    this.unread();
  },
  methods: {
    unread() {
      this.$store.dispatch("user/unread").then(() => {
        this.num = this.$store.getters.noticeNum;
      });
    },
    jump() {
      this.$router.push(
        {
          path: "/system/notice",
          query: { tab: 1, status: 0 }
        },
        () => {}
      );
    }
  }
};
</script>

<style lang="scss" scoped>
.lingdang {
  display: inline-block;
  position: relative;
  vertical-align: top;
  .icon-lingdang {
    font-size: 28px;
    margin-right: 20px;
  }

  div {
    /* display: inline-block; */
    width: 30px;
    height: 30px;
    text-align: center;
    font-size: 18px;
    line-height: 30px;
    background-color: red;
    border-radius: 50%;
    color: #fff;
    -webkit-transform: scale(0.9);
    transform: scale(0.7);
    position: absolute;
    top: 0px;
    right: 10px;
  }

  &:hover {
    cursor: pointer;
  }
}
</style>
